let nums = [0, 1, 2, 4, 5, 7]
var summaryRanges = function (nums) {
    if (nums.length === 0) {
        return []
    }
    let left = 0
    let right = 0
    let arr = []
    for (let i = 1; i < nums.length; i++) {
        if (nums[i] === nums[i - 1] + 1) {
            right = i
        } else {
            if (left === right) {
                arr.push(`${nums[left]}`)
            } else {
                arr.push(`${nums[left]}->${nums[right]}`)
            }
            left = i
            right = i
        }
    }
    if (left === right) {
        arr.push(`${nums[left]}`)
    } else {
        arr.push(`${nums[left]}->${nums[right]}`)
    }
    return arr
};
console.log(summaryRanges(nums));
